﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MubiSDK.LoggingLib.Helper
{
    /// <summary>
    /// 针对日志系统组件提供日期时间相关的工具方法
    /// </summary>
    public class DateTimeHelper
    {
        /// <summary>
        /// 获取当前的Unix时间戳
        /// </summary>
        /// <param name="isMilliseconds">是否获取毫秒级时间戳（默认false，返回秒级）</param>
        /// <returns>Unix时间戳</returns>
        public static long GetCurrentTimestamp(bool isMilliseconds = false)
        {
            if (isMilliseconds)
            {
                return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            }
            else
            {
                return DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            }
        }
    }
}
